﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Admin.aspx.cs" Inherits="Admin" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>M-APP Photo Diary</title>
<link rel="shortcut icon" href="http://worldbank.thetigerparty.com/favicon.ico" />
<link href="MasterStyle.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript" charset="utf-8">
    $(document).ready(function () {
        $('#submitLoc').hover(
            function () { // Change the input image's source when we "roll on"
                $(this).attr({ src: 'images/LocationSearch_On.png' });
            },
            function () { // Change the input image's source back to the default on "roll off"
                $(this).attr({ src: 'images/LocationSearch.png' });
            }
        );
        $('#submitEmail').hover(
            function () { // Change the input image's source when we "roll on"
                $(this).attr({ src: 'images/EmailSearch_On.png' });
            },
            function () { // Change the input image's source back to the default on "roll off"
                $(this).attr({ src: 'images/EmailSearch.png' });
            }
        );
        $('#DownloadApp').hover(
            function () { // Change the input image's source when we "roll on"
                $(this).attr({ src: 'images/SubmitBtn_On.png' });
            },
            function () { // Change the input image's source back to the default on "roll off"
                $(this).attr({ src: 'images/SubmitBtn.png' });
            }
        );
        $('#AdminLogin').hover(
            function () { // Change the input image's source when we "roll on"
                $(this).attr({ src: 'images/SubmitBtn_On.png' });
            },
            function () { // Change the input image's source back to the default on "roll off"
                $(this).attr({ src: 'images/SubmitBtn.png' });
            }
        );
        $('#Logout').hover(
            function () { // Change the input image's source when we "roll on"
                $(this).attr({ src: 'images/Logout_On.png' });
            },
            function () { // Change the input image's source back to the default on "roll off"
                $(this).attr({ src: 'images/Logout.png' });
            }
        );
    });
	
	function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}
function checkVersion()
{
  var msg = "This site is supported only in Safari, Firefox or Chrome.";
  var ver = getInternetExplorerVersion();

  if ( ver > -1 )
  {
    if ( ver >= 8.0 ) 
      msg = "This site is supported only in Safari, Firefox or Chrome.";
	   alert( msg );
  } else {
      msg = "This site is supported only in Safari, Firefox or Chrome.";
	  alert( msg );
  }
 
}

	
</script>
<SCRIPT TYPE="text/javascript">
<!--
    function submitenter(myfield, e) {
        var keycode;
        if (window.event) keycode = window.event.keyCode;
        else if (e) keycode = e.which;
        else return true;

        if (keycode == 13) {
            myfield.form.submit();
            return false;
        }
        else
            return true;
    }
//-->
</SCRIPT>
<script>

    function clearText(thefield) {
        if (thefield.defaultValue == thefield.value)
            thefield.value = ""
    } 
</script>
</head>

<body>
    <form id="form1" runat="server">
<div class="MainContainer_admin">
	
  <img src="images/Mapp_Logo.png" class="LogoImage" />
    
  <div class="SortForm">
        <input id="Txt_Email" name="Txt_Email" type="text" class="textInput" onKeyPress="return submitenter(this,event)"/>
    <br />
        <asp:Button ID="Bt_EmailSearch" runat="server" Text="" 
            onclick="Bt_EmailSearch_Click" />
    </div>
    
  <div class="AdminTable">
        <asp:ListView ID="ListView1" runat="server" DataSourceID="LinqDataSource1" 
            DataKeyNames="ID" InsertItemPosition="LastItem" >
           
            <ItemTemplate>
              <div class="photoInfo" id="photoInfoDisplay">
                    <asp:Image id="ImageNameLabel" runat="server" AlternateText='<%#Eval("ImageName") %>' ImageUrl='<%# Eval("ImageName") %>'  width="106" height="80" hspace="0" style="vertical-align:top; float:left; margin-left: 2px; overflow:hidden;"/>
                    <div class="EmailInfo">
                        <strong>Email:</strong> <span style="float:right; margin-right:20px;"><asp:Label ID="EmailLabel" runat="server" Text='<%# Eval("Email") %>' /></asp:Label></span><br />
                        <strong>User ID:</strong>  <span style="float:right; margin-right:20px;"> <asp:Label ID="UserID" runat="server" Text='<%# Eval("UserID") %>' /></asp:Label></span><br />
			            <span style="font-size:10px;"><strong>Device ID:</strong>  <span style="float:right; margin-right:20px;"><asp:Label ID="DeviceIDLabel" runat="server" Text='<%# Eval("DeviceID") %>' /></asp:Label></span></span>
                    </div>
                    <div class="MessageDisplay">
                        <strong>Message:</strong><br /><asp:Label ID="UserTextLabel" runat="server" Text='<%# Eval("UserText") %>' />
                    </div>
                    <div class="LocationInfo">
                        <strong>Lat: &nbsp;&nbsp;</strong> <span style="float:right; margin-right:16px;"><asp:Label ID="LatitudeLabel" runat="server" Text='<%# Eval("Latitude") %>' /></asp:Label></span><br />
                        <strong>Long: </strong> <span style="float:right; margin-right:16px;"><asp:Label ID="LongitudeLabel" runat="server" Text='<%# Eval("Longitude") %>' /></asp:Label></span>
                    </div>
                 <span style="float:right; margin-right:20px; padding:2px;"><asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" /><asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                    Text="Delete" /></span>
                <br />
                <br />
                </div>
            </ItemTemplate>
            <EditItemTemplate>
                <div class="photoInfoEdit" id="photoInfoDisplay">
                    <asp:TextBox ID="ImageNameTextBox" runat="server" Text='<%# Bind("ImageName") %>' width="106" height="80" hspace="0" style="vertical-align:top; float:left; margin-left: 2px; overflow:hidden;"/>
                    <div class="EmailInfo">
                        <strong>Email:</strong>  <span style="float:right; margin-right:20px;; padding:2px;"><asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>'  Width="80" /></asp:TextBox></span><br />
                       <span style="position:relative; top:16px;"> <strong>User ID:</strong> </span> <span style="float:right; margin-right:20px;; padding:2px;"><asp:TextBox ID="UserID" runat="server" Text='<%# Bind("UserID") %>'  Width="80" /></asp:TextBox></span><br /><br />
			            <span style="font-size:10px;"><span style="position:relative; top:16px;"> <strong>Device ID:</strong> </span> <span style="float:right; margin-right:20px;; padding:2px;"><asp:TextBox ID="DeviceIDTextBox" runat="server" Text='<%# Bind("DeviceID") %>'  Width="20" /></asp:TextBox></span></span>
                    </div>
                    <div class="MessageDisplay">
                        <strong>Message:</strong><br /><span style="padding:2px;"><asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("UserText") %>'  rows="5" TextMode="multiline" /></asp:TextBox></span>
                    </div>
                    <div class="LocationInfo">
                        <strong>Lat: &nbsp;&nbsp;</strong> <span style="float:right; margin-right:16px; padding:2px;"><asp:TextBox ID="LatitudeTextBox" runat="server" Text='<%# Bind("Latitude") %>' Width="80" /></asp:TextBox></span><br />
                       <span style="position:relative; top:16px;">  <strong>Long: </strong> </span><span style="float:right; margin-right:16px; padding:2px;"><asp:TextBox ID="LongitudeTextBox" runat="server" Text='<%# Bind("Longitude") %>'  Width="80"  /></asp:TextBox></span>
                    </div>
                 <span style="float:right; margin-right:20px;"><asp:Button ID="UpdateButton" runat="server" CommandName="Update" 
                    Text="Update" /><asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                    Text="Cancel" /></span>
                <br />
                <br />
                </div>
            </EditItemTemplate>
            <EmptyDataTemplate>
                <span>No data was returned.</span>
            </EmptyDataTemplate>
            <InsertItemTemplate>
            <strong>NEW ENTRY</strong><br />
                <div class="photoInfoEdit" id="photoInfoEdit">
                <div class="uploadImage"><strong> Upload Image: </strong><br /><asp:FileUpload ID="ImageUpload" BorderWidth="30"  width="12" height="20"  runat="server"/></div>
                    <div class="EmailInfo" id="new">
                        <strong>Email:</strong>  <span style="float:right; margin-right:20px;; padding:2px;"><asp:TextBox ID="EmailTextBox" runat="server" Text='<%# Bind("Email") %>'  Width="80" /></span><br />
                        <span style="position:relative; top:16px;"> <strong>User ID:</strong> </span> <span style="float:right; margin-right:20px;; padding:2px;"><asp:TextBox ID="UserID" runat="server" Text='<%# Bind("UserID") %>'  Width="80" /></span><br /><br />
			            <span style="font-size:10px;"><span style="position:relative; top:16px;"> <strong>Device ID:</strong>  <span style="float:right; margin-right:20px;; padding:2px;"><asp:TextBox ID="DeviceIDTextBox" runat="server" Text='<%# Bind("DeviceID") %>'  Width="20" /></span></span><br />
                    </div>
                    <div class="MessageDisplay">
                        <strong>Message:</strong><br /><span style="padding:2px;"><asp:TextBox ID="UserTextTextBox" runat="server" Text='<%# Bind("UserText") %>' rows="2" TextMode="multiline"/></span>
                       
                    </div>
                    <div class="LocationInfo">
                        <strong>Lat: &nbsp;&nbsp;</strong> <span style="float:right; margin-right:16px; padding:2px;"><asp:TextBox ID="LatitudeTextBox" runat="server" Text='<%# Bind("Latitude") %>' Width="80" /></span><br />
                       <span style="position:relative; top:16px;">  <strong>Long: </strong> </span><span style="float:right; margin-right:16px; padding:2px;"><asp:TextBox ID="LongitudeTextBox" runat="server" Text='<%# Bind("Longitude") %>' Width="80"/></span>
                    </div>
                 <span style="float:right; margin-right:20px;"><asp:Button ID="InsertButton" runat="server" CommandName="Insert" 
                    Text="Insert" /><asp:Button ID="CancelButton" runat="server" CommandName="Cancel" 
                    Text="Clear" /></span>
                <br />
                <br />
                </div>
            </InsertItemTemplate>
            
            <LayoutTemplate>
                <div style="">
                    <asp:DataPager ID="DataPager1" runat="server" PageSize="5">
                        <Fields>
                            <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" 
                                ShowNextPageButton="false" ShowPreviousPageButton="True" />
                            <asp:NumericPagerField />
                            <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" 
                                ShowNextPageButton="True" ShowPreviousPageButton="false" />
                        </Fields>
                    </asp:DataPager>
                </div>
                <div ID="itemPlaceholderContainer" runat="server" 
                    style="">
                    <span runat="server" id="itemPlaceholder" />
                </div>
            </LayoutTemplate>
            <SelectedItemTemplate>
                <div class="photoInfo" id="photoInfoDisplay">
                    <asp:Image id="ImageNameLabel" runat="server" AlternateText='<%# Eval("ImageName") %>' ImageUrl='<%# Eval("ImageName") %>'  width="106" height="80" hspace="0" style="vertical-align:top; float:left; margin-left: 2px; overflow:hidden;"/>
                    <div class="EmailInfo">
                        <strong>Email:</strong> <span style="float:right; margin-right:20px;"><asp:Label ID="EmailLabel" runat="server" Text='<%# Eval("Email") %>' /></asp:Label></span><br />
                         <strong>User ID:</strong>   <span style="float:right; margin-right:20px;"><asp:Label ID="UserID" runat="server" Text='<%# Eval("UserID") %>' /></asp:Label></span><br />
			             <span style="font-size:10px;"><strong>Device ID:</strong>  <span style="float:right; margin-right:20px;"><asp:Label ID="DeviceIDLabel" runat="server" Text='<%# Eval("DeviceID") %>' /></span></span>
                    </div>
                    <div class="MessageDisplay">
                        <asp:Label ID="UserTextLabel" runat="server" Text='<%# Eval("UserText") %>' />
                    </div>
                    <div class="LocationInfo"><br />
                        <strong>Lat: &nbsp;&nbsp;</strong> <span style="float:right; margin-right:20px;"><asp:Label ID="LatitudeLabel" runat="server" Text='<%# Eval("Latitude") %>' /></asp:Label></span><br />
                        <strong>Long: </strong> <span style="float:right; margin-right:20px;"><asp:Label ID="LongitudeLabel" runat="server" Text='<%# Eval("Longitude") %>' /></asp:Label></span>
                    </div>
                <span style="float:right; margin-right:20px;"><asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
                <asp:Button ID="DeleteButton" runat="server" CommandName="Delete" 
                    Text="Delete" /></span>
                <br />
                <br />
                </div>
            </SelectedItemTemplate>
        </asp:ListView>
        <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
            ContextTypeName="WBDataClassesDataContext" EntityTypeName="" 
            TableName="BB_UPLOAD_DATAs" EnableDelete="True" EnableInsert="True" 
            EnableUpdate="True" OrderBy="ID desc" Where="Email == @Email" 
            oninserting="LinqDataSource1_Inserting">
            <WhereParameters>
                <asp:SessionParameter Name="Email" SessionField="Email" Type="String" />
            </WhereParameters>
        </asp:LinqDataSource>
 </div>
  <div class="BottomLayer_admin">
  <span class="formTitle">DOWNLOAD APP</span><br />
            <input name="Txt_Downloademail" type="text" class="textInput2" value="Enter Your Email" onfocus="clearText(this)"/>
            <asp:ScriptManager ID="MainScriptManager" runat="server"/>
            <asp:UpdatePanel ID="DownloadPanel" runat="server">
            <ContentTemplate>
                <asp:Button ID="Bt_DownloadLink" class="submit" runat="server" Text="" onclick="Bt_DownloadLink_Click" />
            </ContentTemplate>
            </asp:UpdatePanel>
        </div>
  
   <div class="AdminNav">
        <asp:Button ID="Bt_Logout" class="Logout" runat="server" Text="" width="70" 
            height="24" border="0" onclick="Bt_Logout_Click"/>
   </div>
</div>
  
  <span class="footer"><br />
  This is M-APP's mobile photo blogging project based on Blackberry. Please contact <a href="mailto:wbmapp@gmail.com">wbmapp@gmail.com</a> for more details.  This site is best viewed in Safari, Firefox or Chrome.</span>
 
    </form>
 
</body>
</html>

